using System;
using System.Windows;

using EMan.Interface.Common;

namespace EMan.GUI.Common
{
  public static class ViewEnumExtensions
  {
    public static MessageBoxImage ToWpf( this MessageType value )
    {
      MessageBoxImage result;
      switch( value )
      {
        case MessageType.None:
          result = MessageBoxImage.None;
          break;
        case MessageType.Error:
          result = MessageBoxImage.Error;
          break;
        case MessageType.Question:
          result = MessageBoxImage.Question;
          break;
        case MessageType.Warning:
          result = MessageBoxImage.Warning;
          break;
        case MessageType.Information:
          result = MessageBoxImage.Information;
          break;
        default:
          throw new ArgumentOutOfRangeException( "value" );
      }
      return result;
    }

    public static MessageBoxButton ToWpf( this PossibleAnswers value )
    {
      MessageBoxButton result;
      switch(value)
      {
        case PossibleAnswers.Ok:
          result = MessageBoxButton.OK;
          break;
        case PossibleAnswers.OkCancel:
          result = MessageBoxButton.OKCancel;
          break;
        case PossibleAnswers.YesNoCancel:
          result = MessageBoxButton.YesNoCancel;
          break;
        case PossibleAnswers.YesNo:
          result = MessageBoxButton.YesNo;
          break;

        case PossibleAnswers.AbortRetryIgnore:
        case PossibleAnswers.RetryCancel:
          throw new NotSupportedException();

        default:
          throw new ArgumentOutOfRangeException( "value" );
      }
      return result;
    }

    public static Answer ToCommon( this MessageBoxResult value )
    {
      Answer result;
      switch( value )
      {
        case MessageBoxResult.None:
          result = Answer.None;
          break;
        case MessageBoxResult.OK:
          result = Answer.Ok;
          break;
        case MessageBoxResult.Cancel:
          result = Answer.Cancel;
          break;
        case MessageBoxResult.Yes:
          result = Answer.Yes;
          break;
        case MessageBoxResult.No:
          result = Answer.No;
          break;
        default:
          throw new ArgumentOutOfRangeException( "value" );
      }
      return result;
    }
  }

}